using Framework;
using UnityEngine;

namespace Game
{
    public class BaseWarriorEntity : BaseEntity
    {
        public CharacterMotor Character { get; protected set; }

        public override void Init()
        {
        }

        public async FTask RefreshCharacter(string nameWarrior)
        {
            string pathWarrior = AssetUtility.GetWarriorPath(nameWarrior);
            GameObject prefabWarrior = await GameEntry.Resource.LoadPrefabAsync(pathWarrior);
            GameObject goWarrior = GameObject.Instantiate(prefabWarrior);
            this.Character = goWarrior.GetComponent<CharacterMotor>();
            goWarrior.transform.ResetRPS();
            this.OnCharacterRefresh();
        }

        public virtual void OnCharacterRefresh()
        {
        }

        public override void OnDispose()
        {
            if (this.Character)
            {
                this.Character.Destroy();
                this.Character = null;
            }
        }

    }
}